home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programmer Power Tools
/
Programmer Power Tools.iso
/
icon
/
version5
/
roman.icn
< prev
next >
Wrap
Text File
|
1986-11-25
|
611b
|
24 lines
#
# R O M A N N U M E R A L S
#
# This program takes Arabic numerals from standard input and writes
# the corresponding Roman numerals to standard outout.
procedure main()
local n
while n := read() do
write(roman(n) | "cannot convert")
end
procedure roman(n)
local arabic, result
static equiv
initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
integer(n) > 0 | fail
result := ""
every arabic := !n do
result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
if find("*",result) then fail else return result
end